<template>
{{#if ctrl.psSysPFPlugin}}
    {{> @macro/plugins/widget/widget-use.hbs appPlugin=ctrl.psSysPFPlugin}}
{{else}}
    <div :class="classNames" :id="controlID">
        {{#each ctrl.rootPSPanelItems as | panelItem |}}
        {{> @macro/widgets/panel-detail/include-panel.hbs type=panelItem.itemType item=panelItem isMultiData=false panel=ctrl}}
        {{/each}}
    </div>
{{/if}}
</template>

// 基于template/src/widgets/\{{appEntities}}/\{{ctrls@PANEL}}-panel/\{{spinalCase ctrl.codeName}}-panel.vue.hbs生成
<script setup lang="ts">
{{> @macro/plugins/widget/widget-import.hbs ctrl=ctrl}}
{{> @macro/plugins/ctrl-item/ctrl-item-import.hbs panel=ctrl}}
import { AppCtrlPos, AppScrollContainer, AppSimpleFlexContainer, AppStandardContainer, AppTabPanel, AppTabPage } from '@components/layout-element/structure';
{{> @macro/widgets/ctrl/import-ctrl.hbs ctrls=ctrl.psControls appEntity=appEntity}}
import { model } from "./{{spinalCase ctrl.codeName}}-panel-model";
import { {{pascalCase ctrl.name}}ControlVO } from './{{spinalCase ctrl.codeName}}-panel-vo';
import { IContext, IParam, createUUID, ILoadingHelper, PanelActionType, ICtrlDataAction, IPanelAbility, IPanelController, IPanelControllerParams, IPanelStore, PanelController, IViewCtx, IEvent } from "@/core";
import { useNavParamsBind, useEventBind, getCtrlClassNames, handleComponentAction } from '@/hooks/use-ctrl';
import PanelService from "@/core/modules/ctrl-service/panel-service";

// 输入参数
{{> @macro/widgets/ctrl/ctrl-props.hbs
    props="openView?: Function;
    newView?: Function;
    actions: ICtrlDataAction;    
    isLoadDefault?: boolean;
    data?: IParam;
    viewType?: string;
    "
}}

// emit
{{> @macro/common/emit.hbs name="ctrl" actionType="PanelActionType" ability="IPanelAbility"}}

//  部件样式名
const classNames = computed(() => {
    const classNames = getCtrlClassNames(model, props);
    Object.assign(classNames, {
        'panel-layout': true,
        [`panel-layout--${model.layoutMode.toLowerCase()}`]: true,
    });
    return classNames;
});

const controlID = createUUID();     

// 部件服务
const ctrlService = new PanelService<{{pascalCase ctrl.name}}ControlVO>({{pascalCase ctrl.name}}ControlVO, model.entityCodeName)

const params: IPanelControllerParams<PanelActionType, IPanelAbility> = {
    name: props.name,
    model,
    evt,
    controlID,
    data: props.data,
    viewType: props.viewType,
    pLoadingHelper: props.pLoadingHelper,  
    actions: props.actions,
    openView: props.openView,
    newView: props.newView,
    closeView: props.closeView,
    isLoadDefault: props.isLoadDefault,
    ctrlService: ctrlService,
    pViewCtx: props.pViewCtx,
    handler: (data: IPanelStore) => { return reactive(data); }
};

{{> @macro/common/controller.hbs name="ctrl" IController="IPanelController" store="IPanelStore" ability="IPanelAbility" controller="PanelController"}}
</script>